package com.um.jdy.platform.market.controller;

import com.um.jdy.common.market.entity.dto.FullReduceDTO;
import com.um.jdy.common.market.entity.po.FullReduce;
import com.um.jdy.common.market.entity.vo.FullReduceVO;
import com.um.jdy.common.market.service.FullReduceService;
import com.um.jdy.platform.market.entity.dto.ActivityPageDTO;
import com.um.jdy.platform.market.entity.dto.SaveGroupDTO;
import com.um.jdy.platform.market.entity.dto.SaveReduceDTO;
import com.um.jdy.platform.market.entity.vo.FullReduceResultVO;
import com.um.jdy.platform.market.manager.FullReduceManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.controller.BasePlusController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ListDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器：满减活动表
 */
@RestController
@RequestMapping("/api/v1/market/full_reduce")
@Api(tags = "FullReduceController", description = "满减活动表")
@ApiPermission("full_reduce")
@TokenRequired
public class FullReduceController extends BasePlusController<FullReduceManager, FullReduceService, FullReduce, FullReduceDTO, FullReduceVO, ActivityPageDTO, ListDTO> {

    @ApiPermission("save_reduce")
    @ApiOperation("保存满减活动")
    @PostMapping("save_reduce")
    public Response saveReduce(@RequestBody SaveReduceDTO saveReduceDTO) {
        boolean result = manager.saveReduce(saveReduceDTO);
        return result ? Response.success() : Response.failed();
    }

    @ApiPermission("get_reduce")
    @ApiOperation("获取满减活动")
    @PostMapping("get_reduce")
    public Response<FullReduceResultVO> getReduce(@RequestBody FullReduceDTO reduceDTO) {
        return Response.success(manager.getReduce(reduceDTO));
    }

}
